<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Vue.js 组件传值</title>
        
        <script src="../../../js/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <son @msgfromson="showMsg"></son>
        </div>
        
        <script>
            var son = {
                template: '<button @click="sendMsg">儿子回应</button>',
                methods: {
                    sendMsg: function() {
                        this.$emit('msgfromson', '汪汪！汪汪汪汪！');
                    }
                }
            };
            new Vue({
                el: '#app',
                methods: {
                    showMsg: function(msg) {
                        alert(msg);
                    }
                },
                components: {
                    son
                }
            });
        </script>
    </body>
</html>